const app = getApp();
var {
  Api
} = require('../../api/api')
const network = require("../../api/network.js");
var WxParse = require('../../api/wxParse/wxParse.js');
Component({
  /**
   * 组件的属性列表
   */
  properties: {
    show: {
      type: Boolean,
      value: false,
      observer: 'showwatch1',
    },
    jinqun: {
      type: Object,
      value: {}
    }

  },
  /**
   * 组件的初始数据
   */
  data: {
    price: '',
    info: '',
    can:'',
    show2: false, //激活弹框的隐藏
    show3: false, //进群弹框
    domain: Api.domain,
    ios: app.globalData.ios, //是否为ios
  },
  attached() {
    this.setData({
      price: network.get('can').big_price,
      info: network.get('can').big_info,
      can: wx.$cache.get('can'),
      ios: app.globalData.ios, //是否为ios
    })
    console.log(app.globalData.ios)
    this.wxParse()
  },
  /**
   * 组件的方法列表
   */
  methods: {
    
     //数据变化显示
  showwatch1(newDate, oldDate){
    console.log("show11121121214444");
    this.setData({
      price: network.get('can').big_price,
      info: network.get('can').big_info,
      can: wx.$cache.get('can'),
      ios: app.globalData.ios, //是否为ios
    })
  },

    close() {
      this.setData({
        show: false
      })
    },
    bay() { //价钱购买
      this.triggerEvent('bay')
    },
    gomian() { //激活码弹框出来
      this.setData({
        show2: true,
        show: false
      })
    },
    zhi(e) { //激活码确定
      var that = this
      var params = {
        type: 2,
        code: e.detail
      }
      wx.$http.get(wx.$get.big_qualifications, {
        type: 2,
        code: e.detail
      }).then(res => {
        var pageArr = getCurrentPages();
        var thisPage = pageArr[pageArr.length - 1];
        thisPage.init2();
        wx.showToast({
          title: '兑换成功',
          icon: 'success',
          duration: 2000
        })
        that.setData({
          show2: false,
          show3: true
        })
        that.triggerEvent('init', {})
      })
      // network.requestLoading(Api.GET.big_qualifications, params, 1, '', 'GET', '', function (res) { //成功的方法
      //   console.log('激活码购买大题', res)
      // var pageArr = getCurrentPages();
      // var thisPage = pageArr[pageArr.length - 1];
      // thisPage.init2();
      //   wx.showToast({
      //     title: '兑换成功',
      //     icon: 'success',
      //     duration: 2000
      //   })
      //   that.setData({
      //     show2: false,
      //     show3: true
      //   })
      //   that.triggerEvent('init', {})
      // }, function () {})
    },
    wxParse() {
      var that = this;
      WxParse.emojisInit('[]', "/wxParse/emojis/", {
        "00": "00.gif",
        "01": "01.gif",
        "02": "02.gif",
        "03": "03.gif",
        "04": "04.gif",
        "05": "05.gif",
        "06": "06.gif",
        "07": "07.gif",
        "08": "08.gif",
        "09": "09.gif",
        "09": "09.gif",
        "10": "10.gif",
        "11": "11.gif",
        "12": "12.gif",
        "13": "13.gif",
        "14": "14.gif",
        "15": "15.gif",
        "16": "16.gif",
        "17": "17.gif",
        "18": "18.gif",
        "19": "19.gif",
      });
      /**
       * html解析示例
       */
      var article = network.get('can').big_info;
      WxParse.wxParse('article', 'html', article, that, 5);
    },
  }
})